package com.itheima.tlias.mapper;

import com.itheima.tlias.pojo.dto.SelectStudentDTO;
import com.itheima.tlias.pojo.dto.StudentCountDataDTO;
import com.itheima.tlias.pojo.entity.Student;
import com.itheima.tlias.pojo.po.InsertStudentParam;
import com.itheima.tlias.pojo.po.SelectStudentPageParam;
import com.itheima.tlias.pojo.po.UpdateStudentParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {
    int insertStudent(InsertStudentParam param);

    List<SelectStudentDTO> selectStudentByPage(SelectStudentPageParam param);

    @Select("select id, name, no, gender, phone, id_card, is_college, address, degree, graduation_date, clazz_id from stu where id = #{id}")
    Student selectStudentById(Integer id);

    int updateStudent(UpdateStudentParam param);


    Student selectStudentUnique(SelectStudentDTO dto);

    int batchDeleteStudentByIds( List<Integer> ids);
    @Select("select degree as name , count(degree) as value from stu")
    List<Map<String,Integer>> studentDegreeData();

    @Select(" select c.name as name, count(s.id) as count from stu s\n" +
            "            right join clazz c\n" +
            "            on s.clazz_id = c.id\n" +
            "        group by c.name")
    List<StudentCountDataDTO> studentCountData();
}
